package com.mindskip.xzs.schedule;

import com.mindskip.xzs.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author artka
 * @description: 定时同步
 * @date 2022/9/13 9:15 PM
 */
@Slf4j
@Component
public class Task{

    @Resource
    private QywxService qywxService;
    @Resource
    private NewQuestionService newQuestionService;
    @Resource
    private ExamService examService;
    @Resource
    private DepartmentService departmentService;
    @Resource
    private NewUserService newUserService;
    @Resource
    private ExamPaperService examPaperService;

    public void task() {
        long startTime = System.currentTimeMillis();
        newQuestionService.updateCategorysInCache();
        examService.updateCategorysInCache();
        examService.updateExamKVInCache();
        examPaperService.updatePaperKVInCache();
        qywxService.getDepartAndUserTree(false);
        departmentService.updateDeptsKVInCache();
        newUserService.updateUserKVInCache();
        long endTime = System.currentTimeMillis();
        log.info("定时同步缓存数据成功，耗时:{}秒", (endTime - startTime) / 1000);
    }
}
